﻿using DataStructure;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestProject1
{
    
    
    /// <summary>
    ///This is a test class for BinaryTreeTest and is intended
    ///to contain all BinaryTreeTest Unit Tests
    ///</summary>
    [TestClass()]
    public class BinaryTreeTest
    {
        BinaryTreeNode<String> root = null;
        public BinaryTreeTest()
        {
            root = new BinaryTreeNode<String>()
            {
                data = "Root",
                Left = new BinaryTreeNode<string>()
                {
                    data = "left1",
                    Left = new BinaryTreeNode<string>()
                    {
                        data = "Left1-1"
                    },
                    Right = new BinaryTreeNode<string>()
                    {
                        data = "Right1-2"
                    }

                },

                Right = new BinaryTreeNode<string>()
                {
                    data = "right1",
                    Left = new BinaryTreeNode<string>()
                    {
                        data = "Left2-1"
                    },
                    Right = new BinaryTreeNode<string>()
                    {
                        data = "Right2-2"
                    }
                }
            };

        }
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


       
        /// <summary>
        ///A test for InOrderTraverse
        ///</summary>
        [TestMethod()]
        public void InOrderTraverseTest()
        {
            BinaryTree.InOrderTraverse<string>(root, (node) => { Console.WriteLine(node.data); });
        }

        [TestMethod()]
        public void InOrderTraverseInStackTest()
        {
            BinaryTree.InOrderTraverseInStack<string>(root, (node) => { Console.WriteLine(node.data); });
        }
        [TestMethod()]
        public void InOrderTraverseInStack2Test()
        {
            BinaryTree.InOrderTraverseInStack2<string>(root, (node) => { Console.WriteLine(node.data); });
        }


        /// <summary>
        ///A test for LevelTraverse
        ///</summary>
        [TestMethod()]
        public void LevelTraverseTest()
        {
            BinaryTree tree = null; // TODO: Initialize to an appropriate value
            BinaryTree.LevelTraverse(tree);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for PostOrderTraverse
        ///</summary>
        [TestMethod()]
        public void PostOrderTraverseTest()
        {
            BinaryTree.PostOrderTraverse<string>(root, (node) => { Console.WriteLine(node.data); });
        }

        /// <summary>
        ///A test for PreOrderTraverse
        ///</summary>
        [TestMethod()]
        public void PreOrderTraverseTest()
        {
            BinaryTree.PreOrderTraverse<string>(root, (node) => { Console.WriteLine(node.data); });
        }
    }
}
